import cv2
import numpy as np
import matplotlib.pyplot as plt

#
# bgr_img = cv2.imread("./2.jpg")
#
# # bgr_img = cv2.imread("./demo.jpeg")
# gray_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2GRAY)
# th, binary = cv2.threshold(gray_img, 0, 255, cv2.THRESH_OTSU)
#
# # plt.imshow()
# # plt.show()
#
# contours, hierarchy = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# print(contours)
#
# cv2.drawContours(bgr_img, contours, -1, (0, 0, 255), 3)
#
#
# plt.imshow(bgr_img[:,:,::-1])
# plt.show()
#
# bounding_boxes = [cv2.boundingRect(cnt) for cnt in contours]
#
# for bbox in bounding_boxes:
#     [x, y, w, h] = bbox
#     cv2.rectangle(bgr_img, (x, y), (x + w, y + h), (0, 255, 0), 2)



# cv2.imshow("name", bgr_img)
# cv2.waitKey(0)

# plt.imshow(bgr_img[:,:,::-1])
# plt.show()


import cv2

img = cv2.imread("./2.jpg")

print('Original Dimensions : ', img.shape)

width = 524
height = img.shape[0]  # keep original height
height = 524
dim = (width, height)

# resize image
resized = cv2.resize(img, dim, interpolation=cv2.INTER_AREA)

print('Resized Dimensions : ', resized.shape)
plt.imshow(resized[:,:,::-1])
plt.show()
img = cv2.imwrite("./dilireba.png",resized)

# cv2.imshow("Resized image", resized)
# cv2.waitKey(0)
# cv2.destroyAllWindows()